﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for clsNHATKYXOAPHI
/// </summary>
public class clsNHATKY_XOAPHI
{
	public clsNHATKY_XOAPHI()
	{
		//
		// TODO: Add constructor logic here
		//
    }

    #region Select
    public static DataTable Select()
    {
        DataTable dt = new DataTable();
        // Tham so
        DatabaseConnect connect = new DatabaseConnect();
        try
        {
            dt = connect.GetSelectCommand("NHATKYXOAPHI_Select", null);
        }
        catch { }
        return dt;
    }
    public static DataTable GetByF_MACN(string F_MACN)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@F_MACN", F_MACN);
        try
        {
            dt = connect.GetSelectCommand("NHATKYXOAPHI_GetByF_MACN", para);
        }
        catch { }
        return dt;
    }
    #endregion

    #region Insert
    public static string Insert(Guid F_STT, string F_MAHV, int F_MANV, int F_STTCAPLOP, DateTime F_NGAYDONGPHI, string F_MADT, int F_LANTHU, float F_SOTHANG, decimal F_SOTIENQD, decimal F_SOTIENPHAT, decimal F_SOTIENHB, decimal F_TIENTHUCTHU, string F_GHICHU, string F_TIENBANGCHU, bool F_DONG_RUT, int ID, int F_NGUOIXOA, DateTime F_NGAYXOA, string F_NOIDUNGTHU) 
    {
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        object[] values = { F_STT, F_MAHV, F_MANV, F_STTCAPLOP, F_NGAYDONGPHI, F_MADT, F_LANTHU, F_SOTHANG, F_SOTIENQD, F_SOTIENPHAT, F_SOTIENHB, F_TIENTHUCTHU, F_GHICHU, F_TIENBANGCHU, F_DONG_RUT, ID, F_NGUOIXOA, F_NGAYXOA, F_NOIDUNGTHU };
        string[] parameters = { "@F_STT", "@F_MAHV", "@F_MANV", "@F_STTCAPLOP", "@F_NGAYDONGPHI", "@F_MADT", "@F_LANTHU", "@F_SOTHANG", "@F_SOTIENQD", "@F_SOTIENPHAT", "@F_SOTIENHB", "@F_TIENTHUCTHU", "@F_GHICHU", "@F_TIENBANGCHU", "@F_DONG_RUT", "@ID", "@F_NGUOIXOA", "@F_NGAYXOA", "@F_NOIDUNGTHU" };
        SqlParameter[] para = new SqlParameter[parameters.Length];
        for (int i = 0; i < parameters.Length; i++)
        {
            para[i] = new SqlParameter(parameters[i], values[i]);
        }
        try
        {
            connect.ExecuteQuery("NHATKYXOAPHI_Insert", para);
            return "OK";
        }
        catch 
        {
            return "ERR";
        }
    }
    #endregion

    #region Delete
    public static string Delete(Guid ID)
    {
        DatabaseConnect connect = new DatabaseConnect();
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@ID", ID);
        try
        {
            connect.ExecuteQuery("NHATKY_XOAPHI_Delete", para);
            return "OK";
        }
        catch
        {
            return "ERR";
        }
    }
    #endregion

    #region DeleteAll
    public static string DeleteAll()
    {
        DatabaseConnect connect = new DatabaseConnect();        
        try
        {
            connect.ExecuteQuery("NHATKY_XOAPHI_DeleteAll", null);
            return "OK";
        }
        catch
        {
            return "ERR";
        }
    }
    #endregion
}